import React, { Component } from 'react';
import { Table } from '@icedesign/base';

// MOCK 数据，实际业务按需进行替换
const getData = () => {
  return Array.from({ length: 10 }).map((item, index) => {
    return {
      rank: `${index + 1}`,
      developer: '淘小宝',
      cost: `123${index}`,
      score: `8${index}.${index}`,
    };
  });
};

export default class CustomTable extends Component {
  static displayName = 'CustomTable';

  static propTypes = {};

  static defaultProps = {};

  constructor(props) {
    super(props);
    this.state = {
      dataSource: [],
    }
  }

  componentWillMount() {

    this.LoadDeviceData()

  }

  LoadDeviceData() {
    let data = [];
    this.props.pa.then(res => {
      if (res.data.status == 200) {
        data = res.data.data
        // let result = []
        // console.log(data)
        const dataSource = data.map((item,index) => {
          return { // 必要格式
            num:index,
            item: item.ORG2_NAME,
            count: item.count,
            math:Math.random()
          };
        });
        this.setState({
          dataSource,
        });

        // return data
      } else {
        alert("/api/getPie 接口出错")
      }
      // console.log(data)

    }).catch(err => {
      console.log(err)
      alert("/api/getPie 接口出错" + err)
    });

    // this.props.updateBindingData('RecvDevice');
  }

  render() {

    return (
      <Table dataSource={this.state.dataSource} hasBorder={false}>
        <Table.Column title="排名" dataIndex="num" />
        <Table.Column title="名字" dataIndex="item" />
        <Table.Column title="统计" dataIndex="count" />
        <Table.Column title="分数" dataIndex="math" />
      </Table>
    );
  }
}
